//
// Created by Jisam on 27/09/2024 9:47 PM.
// Solution of  b
//#pragma GCC optimize(3)
#include <bits/stdc++.h>

using namespace std;
#define coutn(x) cout << (x) << "\n"
#define endl "\n"
#define PSI pair<string,int>
#define PII pair<int,int>
#define PDI pair<double,int>
#define PDD pair<double,double>
#define VVI vector<vector<int>>
#define VI vector<int>
#define VS vector<string>
#define PQLI priority_queue<int, vector<int>, less<int>>
#define PQGI priority_queue<int, vector<int>, greater<int>>
#define code_by_jisam ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
typedef long long i64;
typedef unsigned u32;
typedef unsigned long long u64;
typedef __int128 i128;
int dx[] = {-1, 1, 0, 0, 1, 1, -1, -1,};
int dy[] = {0, 0, -1, 1, 1, -1, -1, 1,};
void solution() {
    // 读取点的数量 n 和查询数量 q
    int n, q;
    cin >> n >> q;

    // 初始化向量 a 和映射 mp
    vector<int> a(n + 1);
    map<int, int> mp;

    // 读取每个点的坐标并计算每段区间包含的整数点数量
    for (int i = 1; i <= n; i++) {
        cin >> a[i];

        // 计算第 i 个点在所有区间的总数
        int cnt = (n - 1) + (i - 1) * (n - i);
        mp[cnt]++;
    }

    // 遍历每个点并更新映射 mp 中每个区间包含的整数点数量
    for (int i = 1; i <= n; i++) {
        // 计算第 i 个点到其他点的区间包含的整数点数量
        int cnt = i * (n - i);
        mp[cnt] += (a[i + 1] - a[i] - 1);
    }

    // 处理每个查询
    while (q--) {
        int x;
        cin >> x;
        cout << mp[x] << " ";
    }
    cout << "\n";
}


int main() {
    code_by_jisam;
    i64 T = 1;
    cin >> T;
    while (T--) {
        solution();
    }
    return 0;
}